<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="../lib/vue.js"></script>
    <style>
        .red {
            background-color: red
        }

        .thin {
            font-weight: 100
        }

        .italic {
            font-style: italic
        }

        .active {
            letter-spacing: 1em
        }
    </style>
</head>

<body>
    <div id="app">
        <!-- v-if 每次都删除和创建元素 -->
        <!-- v-show 是改变display属性 -->
        <h2 v-if="flag">这是v-if控制的元素</h2>
        <h2 v-show="flag">这是v-show控制的元素</h2>
        <input type="button" @click="toggle"/>
    </div>
    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                flag:true
            },
            methods: {
                toggle(){
                    this.flag = !this.flag;
                }
            }
        })
    </script>

</body>

</html>